package com.uenpay.im.ui.old.activity.nearby;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.RelativeLayout;

import com.uenpay.im.R;
import com.uenpay.im.callback.IPopupWindowListener;

public class BottomDialogNearBy {

	public static void showBottomDialog(Context mContext,
			final IPopupWindowListener iPopupWindowListener) {
		final Dialog dialog = new Dialog(mContext, R.style.pop_dialog);
		dialog.setContentView(R.layout.pop_dialog_more_nearby);
		Window win = dialog.getWindow();
		win.setGravity(Gravity.BOTTOM);
		win.setWindowAnimations(R.style.dialogWindowAnim);
		dialog.setCanceledOnTouchOutside(true);
		dialog.show();
		win.setLayout(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
				android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
		RelativeLayout singleWoManLayout = (RelativeLayout) dialog
				.findViewById(R.id.signle_woman_layout);
		RelativeLayout singleManLayout = (RelativeLayout) dialog
				.findViewById(R.id.signle_man_layout);
		RelativeLayout allLayout = (RelativeLayout) dialog
				.findViewById(R.id.all_layout);
		RelativeLayout clearLayout = (RelativeLayout) dialog
				.findViewById(R.id.clear_layout);
		if (iPopupWindowListener != null) {
			singleWoManLayout.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					iPopupWindowListener.itemClick(1);
					dialog.dismiss();
				}
			});
			singleManLayout.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					iPopupWindowListener.itemClick(2);
					dialog.dismiss();
				}
			});
			allLayout.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					iPopupWindowListener.itemClick(3);
					dialog.dismiss();
				}
			});
			clearLayout.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					iPopupWindowListener.itemClick(4);
					dialog.dismiss();
				}
			});
		}
	}

}
